package com.xmh.code.generation.util;

import java.io.*;

public class CreateUtils {


    /**
     * 输出文件到指定目录文件夹
     *
     * @param code
     * @param path
     * @param fileName
     * @param fileType
     */
    public static void outFile(String code, String path, String fileName, String fileType) {
        try {
            File file = new File(path + "//" + fileName + "." + fileType);

            if (!file.exists()) {
                new File(path).mkdirs();
                file.createNewFile();
            }
            OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
            BufferedWriter writer = new BufferedWriter(write);
            writer.write(code);
            writer.flush();
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
